
<%@ page import="id.co.gomobile.assessment.Assignment" %>

<%@page import="id.co.gomobile.assessment.Item"%>
<%@page import="org.joda.time.Period"%><html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'assignment.label', default: 'Assignment')}" />
        <title><g:message code="default.show.label" args="[entityName]" /></title>
    </head>
    <body>
    <g:render template="/shared/navigation" />
    
        <div class="body">
        
        <h1><g:message code="default.show.label" args="[entityName]" /></h1>
        
        <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
        </g:if>
        
        
    <div class="dialog">

    <fieldset>
 
            <h3>Assignment Information</h3>
            <div class="dialog">
                <table>
                    <col width="200px" />
                    <tbody>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="assignment.id.label" default="Id" /></td>
                            <td valign="top" class="value">${fieldValue(bean: assignmentInstance, field: "id")}</td>
                        </tr>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="assignment.test.label" default="Test" /></td>
                            <td valign="top" class="value"><g:link controller="test" action="show" id="${assignmentInstance?.test?.id}">${assignmentInstance?.test?.name.encodeAsHTML()}</g:link></td>
                        </tr>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="assignment.user.label" default="User" /></td>
                            <td valign="top" class="value"><g:link controller="user" action="show" id="${assignmentInstance?.user?.id}">${assignmentInstance?.user?.profile.fullname.encodeAsHTML()}</g:link></td>
                        </tr>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="assignment.total.label" default="Total" /></td>
                            <td valign="top" class="value">${assignmentInstance?.total}</td>
                        </tr>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="assignment.startTime.label" default="Start Time" /></td>
                            <td valign="top" class="value"><g:formatDate date="${assignmentInstance?.startTime}" /></td>
                        </tr>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="assignment.expectedEndTime.label" default="Expected End Time" /></td>
                            <td valign="top" class="value"><g:formatDate date="${assignmentInstance?.expectedEndTime}" /></td>
                        </tr>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="assignment.endTime.label" default="End Time" /></td>
                            <td valign="top" class="value"><g:formatDate date="${assignmentInstance?.endTime}" /></td>
                        </tr>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="assignment.timeTaken.label" default="Time Taken" /></td>
                            <td valign="top" class="value">
		                       <% Period period = new Period(assignmentInstance?.startTime.time, assignmentInstance?.endTime.time) %>
		                       ${period.getHours()}:${period.getMinutes()}:${period.getSeconds()}
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <br/>

            <div class="buttons">
                <g:form>
                    <g:hiddenField name="id" value="${assignmentInstance?.id}" />
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </g:form>
            </div>

    </fieldset>
          
          <br/>
          
          <fieldset>
          
            <h3>Result by Category</h3>
            
	    <div class="list">
	    <table>
	        <col width="50" />
	        <col />
	        <col width="150" />
	        <thead>
	            <tr>
	                <th title="Id">Id</th>
	                <th title="Id">Category</th>
	                <th title="Id">Total</th>
	            </tr>
	        </thead>
	        <tbody>
	        <g:each in="${assigmentCategoryPoint}" status="i" var="assigmentCategoryPointInstance">
	            <tr>
	                <td>${i+1}</td>
	                <td>${assigmentCategoryPointInstance.key}</td>
	                <td align="center"><strong>${assigmentCategoryPointInstance.value.total} of ${assigmentCategoryPointInstance.value.of} (${((assigmentCategoryPointInstance.value.total / assigmentCategoryPointInstance.value.of) * 100).round(new java.math.MathContext(4))}%)</strong></td>
	            </tr>
	        </g:each>
	        </tbody>
	    </table>
	    </div>        
          
          </fieldset>

        </div>
    </body>
</html>
